/**
 * 
 */
package gui;

import java.util.Enumeration;

import javax.swing.tree.DefaultMutableTreeNode;

/**
 * @author Administrator
 * 
 */
public class CheckNode extends DefaultMutableTreeNode
{

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1132828805313470951L;

	/** The selected. */
	private boolean isSelected;

	public CheckNode()
	{

	}

	public CheckNode(Object userObject)
	{
		this(userObject, true, false);
	}

	public CheckNode(Object userObject, boolean allowsChildren, boolean isSelected)
	{
		super(userObject, allowsChildren);
		this.isSelected = isSelected;
	}

	public boolean isSelected()
	{
		return this.isSelected;
	}

	public void setSelected(boolean isSelected)
	{
		this.isSelected = isSelected;

		if (this.children != null)
		{
			Enumeration<?> e = this.children.elements();
			while (e.hasMoreElements())
			{
				CheckNode node = (CheckNode) e.nextElement();
				node.setSelected(isSelected);
			}
		}
	}

	// public String toString()
	// {
	// return this.getClass().getName() + "[" + this.getUserObject() + "/" + this.isSelected + "]";
	// }
}
